<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
  <head>
    <meta charset="utf-8">
    <title>接口示例2</title>
    <!-- CSS、JS、IMG等 -->
	<meta th:replace="part/header"></meta>
	<style type="text/css">
		#tbDiv1{
        	padding-left:16px;
        }
        #stat-widget-container1 {
		  text-align: center;
		  margin-bottom: 1em;
		}

		#blueTabDiv ul{
			border-bottom:1px solid blue;
			display:block;
		    float:left;
		    list-style:none;
		    margin:0;
		    padding:0;
		    width:100%;
		}
		#blueTabDiv ul li{
		    float:left;
		}
		#blueTabDiv ul li a{
			background:white;
			color:black;
		    display:block;
		    height:40px;
		    line-height:40px;/*line-height与height等同是使文字垂直居中的一种方法*/
		    text-align:center;
		    width:120px;
		}
		#blueTabDiv ul li a:hover{
			background:blue;
			color:white;
		}
		#blueTabDiv ul li a.active{
			background:blue;
			color:white;
		}
		#blueTabDiv .tabContentDiv{
			border-left: 1px solid blue;
			border-right: 1px solid blue;
			border-bottom: 1px solid blue;
			overflow:auto;
		}
		
		#blueTabDiv .tabContentDiv .infoBlockDiv{
			border:1px solid #aaa;
			margin:10px;
			
		}
		
		#blueTabDiv .tabContentDiv .infoBlockDiv .title{
			background:#e6e6e6;
			height:40px;
		    line-height:40px;
		    padding-left:20px;
		}
		#blueTabDiv .tabContentDiv .infoBlockDiv table{
			margin:10px;
		}
		
		#blueTabDiv .tabContentDiv .infoBlockDiv pre{
			margin-left:10px;
			margin-right:10px;
		}
    </style>
  </head>

  <!-- 从2021年10月30日开始，所有页面都应在此基础上构建 -->
  <body> 
    <!-- 上边的标题栏 -->
    <div class="navbar">
        <div th:replace="part/navbar"></div>
    </div>

    <!-- 左边的导航栏 -->
    <div class="sidebar-nav">
        <div th:replace="part/sidebar"></div>
    </div>
    
    <div class="content">
        
        <!-- 标题在此 -->
        <div class="header">
            <h1 class="page-title">接口示例2</h1>
        </div>
        
        <!-- 页面路径在此 -->
        <ul class="breadcrumb">
            <li><a href="index.html">Home</a> <span class="divider">/</span></li>
            <li class="active">Sample Page 2</li>
        </ul>

        <div class="container-fluid">
            <div class="row-fluid">
				<div class="tab-pane active in" id="profile">
				<!-- 这个div内部就是页面主要内容 -->
				
					<!-- 这个div里是示例接口说明部分 -->
					<div class="block">
				        <div id="page-stats" class="block-body collapse in">
				
				            <div id="stat-widget-container1">
								<table border="0" width="100%" height="100%">
									<tr>
										<td width="132px" height="132px" valign="middle">
											<img src='../images/book.png' width="128" height="128"/>
										</td>
										<td>
											<div id="tbDiv1" padding-left:"">
												<table width="100%" height="100%">
													<tr>
														<td align="left" colspan="2"><B><font size="6">示例接口说明</font></B></td>
													</tr>
													<tr>
														<td align="left" colspan="2">&nbsp;</td>
													</tr>
													<tr>
														<td align="left" width="80"><B><font size="3">描述:</font></B></td>
														<td align="left"><font size="3">本接口意在给用户提供一个简单、不受限、易上手实操的样例，降低用户的学习坡度，熟悉后能易于上手其它接口。</font></td>
													</tr>
													<tr>
														<td align="left"><B><font size="3">接口ID:</font></B></td>
														<td align="left"><font size="3">8972</font></td>
													</tr>
													<tr>
														<td align="left"><B><font size="3">价格:</font></B></td>
														<td align="left"><font size="3">完全免费不受限，申请后立即生效. </font></td>
													</tr>
													<tr>
														<td align="left"><B><font size="3">热度:</font></B></td>
														<td align="left"><font size="3">近 <font color="navy">30</font> 天申请 <font color="navy">168</font> 次。如有疑问请咨询客服:<font color="red">800-688-9786</font></font></td>
													</tr>
												</table>
											</div>
										</td>
										<td width="132px" height="132px">
											<a href="#" class="btn btn-info">申请接口</a>
										</td>
									</tr>
								</table>
				            </div>
				        </div>
				    </div>
			    </div>
			    
			    <!-- 这个div里放的是蓝色选项菜单 -->
			    <div id="blueTabDiv">
			    	<ul>
			    		<li><a id="tabLiA01" href="javascript:chooseTab('tabLiA01','requestParameter')" class="active">接口信息</a></li>
			    		<li><a id="tabLiA02" href="javascript:chooseTab('tabLiA02','backCodeIllustration')">返码说明</a></li>
			    		<li><a id="tabLiA03" href="javascript:chooseTab('tabLiA03','sampleCode')">示例代码</a></li>
			    		<li><a id="tabLiA04" href="javascript:chooseTab('tabLiA04','interfaceDoc')">接口文档</a></li>
			    		<li><a id="tabLiA05" href="javascript:chooseTab('tabLiA05','updateVersion')">升级版本</a></li>
			    	</ul>
			    	
			    	<div class="tabContentDiv">
			    		<div class="infoBlockDiv">
			    			<div class="title">基本信息</div>
			    			
			    			<table>
			    				<tr>
									<td align="left" width="80"><B><font size="3">接口地址:</font></B></td>
									<td align="left"><font size="3" color='navy'>http://localhost:8080/mediacool/interface/gotoSample#profile</font></td>
								</tr>
								<tr>
									<td align="left" colspan="2">&nbsp;</td>
								</tr>
								<tr>
									<td align="left"><B><font size="3">请求方式:</font></B></td>
									<td align="left"><font size="3" color='navy'>GET</font></td>
								</tr>
								<tr>
									<td align="left" colspan="2">&nbsp;</td>
								</tr>
								<tr>
									<td align="left"><B><font size="3">返回格式:</font></B></td>
									<td align="left"><font size="3" color='navy'>JSON</font></td>
								</tr>
								<tr>
									<td align="left" colspan="2">&nbsp;</td>
								</tr>
								<tr>
									<td align="left" width="80"><B><font size="3">请求示例:</font></B></td>
									<td align="left"><font size="3" color='navy'>https://blog.csdn.net/chengqiuming/article/details/100147057</font></td>
								</tr>
								<tr>
									<td align="left" colspan="2">&nbsp;</td>
								</tr>
								<tr>
									<td align="left" colspan="2"><a href="#" class="btn btn-info">测试API</a></td>
								</tr>
								
			    			</table>
			    			<a name="basicInformation" style="display:block">..</a>
			    		</div>
			    		
			    		<!-- 请求参数 -->
			    		<div class="infoBlockDiv">
			    			<div class="title">请求参数<a href="#basicInformation"><img src='../images/arrow_top.png'/></a></div>
			    			
			    			<table>
								<tr>
									<td align="left"><B><font size="3">授权认证方式:</font></B></td>
								</tr>
								<tr><td>&nbsp;</td></tr>
								<tr>
									<td align="left"><font size="3">默认模式</font></td>
								</tr>
								<tr><td>&nbsp;</td></tr>
								<tr>
									<td align="left"><font size="3">需要添加请求header</font></td>
								</tr>
								<tr><td>&nbsp;</td></tr>
								<tr>
									<td align="left"><font size="3">HttpGet get = new HttpGet(url); get.setHeader(“Authorization”, token);</font></td>
								</tr>
								<tr><td>&nbsp;</td></tr>
								<tr>
									<td align="left"><B><font size="3">请求参数:</font></B></td>
								</tr>
								<tr><td>&nbsp;</td></tr>
								<tr><td>
									<table border=1>
										<tr height="40" >
											<td width="150" align="center" style="background-color:#f5f2eb"><font size="3">参数</font></td>
											<td width="150" align="center" style="background-color:#f5f2eb"><font size="3">必选</font></td>
											<td width="150" align="center" style="background-color:#f5f2eb"><font size="3">类型及范围</font></td>
											<td align="center" style="background-color:#f5f2eb"><font size="3">说明</font></td>
										</tr>
										<tr height="50" >
											<td align="center" ><font size="3">keyword</font></td>
											<td align="center" ><font size="3">true</font></td>
											<td align="center" ><font size="3">String</font></td>
											<td align="center" ><font size="3">搜索关键字（公司名称、公司id、注册号或社会统一信用代码）</font></td>
										</tr>
									</table>
								</td></tr>
								<tr><td>&nbsp;</td></tr>
								<tr>
									<td align="left"><font size="3">注意 : 请求参数需要URLEncode。</font></td>
								</tr>
			    			</table>
			    			<a name="requestParameter" style="display:block">..</a>
			    		</div>
			    		
			    		<!-- 返回结果 -->
			    		<div class="infoBlockDiv">
			    			<div class="title">返回结果<a href="#basicInformation"><img src='../images/arrow_top.png'/></a></div>
			    			
			    			<table>
								<tr>
									<td align="left"><font size="3">Json示例:</font></td>
								</tr>
								<tr><td>&nbsp;</td></tr>
							</table>
							
<pre>
{
    "data":[
        {
            "billAmount":5,
            "deliveryListId":"20180001",
            "deliveryOrder":1,
            "geocodingScore":50,
            "isCod":true,
            "latitude":"20180001.22",
            "latitudeJP":"56789.33",
            "longitude":"20180001.33",
            "longitudeJP":"123456.33",
            "orderDetails":[
                {
                    "lapCount":null,
                    "quantity":1,
                    "statusCode":null,
                    "statusNameMobile":null,
                    "trackingNo":"201803200001"
                },
                {
                    "lapCount":4,
                    "quantity":1,
                    "statusCode":"100",
                    "statusNameMobile":"配送準備中",
                    "trackingNo":"201803200002"
                },
                {
                    "lapCount":4,
                    "quantity":1,
                    "statusCode":"300",
                    "statusNameMobile":"持出し",
                    "trackingNo":"201803200003"
                },
                {
                    "lapCount":4,
                    "quantity":1,
                    "statusCode":"100",
                    "statusNameMobile":"配送準備中",
                    "trackingNo":"201803200004"
                },
                {
                    "lapCount":4,
                    "quantity":1,
                    "statusCode":"100",
                    "statusNameMobile":"配送準備中",
                    "trackingNo":"201803200005"
                }
            ],
            "orderNo":"102018032001",
            "receiverAddress1":"東京都足立区足立1-1",
            "receiverAddress2":"東京都足立区足立1-2",
            "receiverName":"吉田　XXX",
            "receiverTelNo":"07012340303",
            "shipperCode":"0030",
            "shortShipperName":"RB",
            "vehicleId":"239"
        }
    ]
}
</pre>
			    		</div>
			    		
			    		
			    		<!-- 返回字段说明 -->
			    		<div class="infoBlockDiv">
			    			<div class="title">返回字段说明<a href="#basicInformation"><img src='../images/arrow_top.png'/></a></div>
			    			
			    			<table>
			    				<tr height="40"  style="background-color:#f5f2eb">
									<td width="25%" align="center"><B><font size="3">返回值字段</font></B></td>
									<td width="25%" align="center"><B><font size="3">字段类型</font></B></td>
									<td width="25%" align="center"><B><font size="3">字段说明</font></B></td>
									<td width="25%" align="center"><B><font size="3">备注</font></B></td>
								</tr>
								<tr height="50" >
									<td align="center" ><font size="3">keyword</font></td>
									<td align="center" ><font size="3">true</font></td>
									<td align="center" ><font size="3">String</font></td>
									<td align="center" ><font size="3">搜索关键字（公司名称、公司id、注册号或社会统一信用代码）</font></td>
								</tr>
								<tr height="50" style="background-color:#f5f2eb">
									<td align="center" ><font size="3">keyword</font></td>
									<td align="center" ><font size="3">true</font></td>
									<td align="center" ><font size="3">String</font></td>
									<td align="center" ><font size="3">搜索关键字（公司名称、公司id、注册号或社会统一信用代码）</font></td>
								</tr>
								<tr height="50" >
									<td align="center" ><font size="3">keyword</font></td>
									<td align="center" ><font size="3">true</font></td>
									<td align="center" ><font size="3">String</font></td>
									<td align="center" ><font size="3">搜索关键字（公司名称、公司id、注册号或社会统一信用代码）</font></td>
								</tr>
								<tr height="50" style="background-color:#f5f2eb">
									<td align="center" ><font size="3">keyword</font></td>
									<td align="center" ><font size="3">true</font></td>
									<td align="center" ><font size="3">String</font></td>
									<td align="center" ><font size="3">搜索关键字（公司名称、公司id、注册号或社会统一信用代码）</font></td>
								</tr>
			    			</table>
			    			
			    			<a name="backCodeIllustration" style="display:block">..</a>
			    		</div>
			    		
			    		<!-- 错误代码 -->
			    		<div class="infoBlockDiv">
			    			<div class="title">错误代码</div>
			    			
			    			<table>
			    				<tr height="40"  style="background-color:#f5f2eb">
									<td width="50%" align="center"><B><font size="3">代码</font></B></td>
									<td width="50%" align="center"><B><font size="3">说明</font></B></td>
								</tr>
								<tr height="50" >
									<td align="center" ><font size="3">keywordkeywordkeywordkeywordkeyword</font></td>
									<td align="center" ><font size="3">truekeywordkeywordkeywordkeywordkeyword</font></td>
								</tr>
								<tr height="50" style="background-color:#f5f2eb">
									<td align="center" ><font size="3">keyword</font></td>
									<td align="center" ><font size="3">true</font></td>
								</tr>
								<tr height="50" >
									<td align="center" ><font size="3">keyword</font></td>
									<td align="center" ><font size="3">true</font></td>
								</tr>
								<tr height="50" style="background-color:#f5f2eb">
									<td align="center" ><font size="3">keyword</font></td>
									<td align="center" ><font size="3">true</font></td>
								</tr>
			    			</table>
			    		</div>
			    		
			    		<!-- 示例代码 -->
			    		<div class="infoBlockDiv">
			    			<div class="title">示例代码<a href="#basicInformation"><img src='../images/arrow_top.png'/></a></div>
			    			
			    			<table>
								<tr>
									<td align="left"><font size="3">Java示例:</font></td>
								</tr>
								<tr><td>&nbsp;</td></tr>
							</table>
							
<pre>
package com.hy.myapp;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import com.hy.myapp.Entity.User;

@Component
public class Interceptor implements HandlerInterceptor{
	private final static Logger logger = LoggerFactory.getLogger(Interceptor.class);
	
    /**
     * 在请求处理之前进行调用（Controller/RestController方法调用之前）
     */
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
    	// System.out.println("有请求来到，其路径="+request.getServletPath());
    	String path = request.getServletPath();
    	if(path.startsWith("/lib/") || path.startsWith("/stylesheets/")|| path.startsWith("/assets/") || path.startsWith("/images/")) {
    		return true;
    	}
    	logger.info("Request coming,whose path={}",path);
    	
    	// 执行权限检查、登录验证、缓存处理等
    	HttpSession session=request.getSession();
    	User user = (User)session.getAttribute("user");
        if(user==null)
        {
            System.out.println("User dosen't login in.");
            try {
				response.sendRedirect(request.getContextPath()+"/");
			} catch (Exception e) {
				e.printStackTrace();
			}
            return false;
        }else {
        	System.out.println("User loginned in.");
        }
    	
        return true;
    }
}
</pre>
<a name="sampleCode" style="display:block">..</a>
			    		</div>
			    		
			    		<!-- 接口文档 -->
			    		<div class="infoBlockDiv">
			    			<div class="title">接口文档<a href="#basicInformation"><img src='../images/arrow_top.png'/></a></div>
			    			
			    			<table>
			    				<tr height="40"  style="background-color:#f5f2eb">
									<td width="50%" align="center"><B><font size="3">文档名称</font></B></td>
									<td width="50%" align="center"><B><font size="3">备注</font></B></td>
								</tr>
								<tr height="50" >
									<td align="center" ><font size="3" color="blue">884-税务评级</font></td>
									<td align="center" ><font size="3">税务评级</font></td>
								</tr>
			    			</table>
			    			
			    			<a name="interfaceDoc" style="display:block">..</a>
			    		</div>
			    		
			    		<!-- 升级版本 -->
			    		<div class="infoBlockDiv">
			    			<div class="title">升级版本<a href="#basicInformation"><img src='../images/arrow_top.png'/></a></div>
			    			
			    			<table>
								<tr>
									<td align="left"><B><font size="3" color='red'>该版本不存在升级接口</font></B></td>
								</tr>
							</table>
			    			<a name="updateVersion" style="display:block">..</a>
			    		</div>
			    	</div>
			    </div>
			    
			    

                <!-- 这里放置的是页脚部分 -->
                <footer>
				    <div th:replace="part/footer"></div>
                </footer>                    
            </div>
        </div>
    </div>
    
    <!-- 这部分是进行菜单设置的 -->
    <script type="text/javascript">
    	chooseSiderbar("accounts-menu",3);
    	
    	function chooseTab(aid,anchor){
    	    var arr=["tabLiA01","tabLiA02","tabLiA03","tabLiA04","tabLiA05"];
    	    
    	    for(var i=0;i<arr.length;i++){
    	    	if(arr[i]==aid){
    	    		document.getElementById(aid).className="active";
    	    	}else{
    	    		document.getElementById(arr[i]).className="";
    	    	}
    	    }
    	    
    	    location.href = "#"+anchor;
    	}
    </script>
    
  </body>
</html>


